import 'package:intl/intl.dart';

class DateUtil{
  static const String DEFAULT_PATTERN = "yyyy-MM-dd HH:mm:ss";
  static const String DATE_PATTERN = "yyyy-MM-dd";

  static format({DateTime date, String pattern = DEFAULT_PATTERN}){
    date = date ?? DateTime.now();
    DateFormat dateFormat = DateFormat(pattern);
    return dateFormat.format(date);
  }

  static parse(String date, {String pattern = DEFAULT_PATTERN}){
    date = date ?? DateTime.now();
    DateFormat dateFormat = DateFormat(pattern);
    return dateFormat.parse(date);
  }
}